Macromedia Flex Article

Learning Flex Basics (Part 3) : Working with Containers


Table of Contents

  1. Introduction
  2. Building the Containers
  3. Create the Application Object
  4. Create a Data Array
  5. Add a TabNavigator Container for Global Navigation
  6. Add an HBox and Panel Containers for Main Views
  7. Add a ViewStack, LinkBar, and Panel Containers for Secondary Views
  8. Add a Form Container
  9. Add a Tile Layout Container and Populate It Using a Repeater
  10. Create a Pseudo Bar Chart Using a Repeater and VBoxes
  11. Complete Code Listing for containers.mxml
  12. Where to Go from Here

Add an HBox Layout and Panel Containers for Main Views

The Flex class library contains a number of layout container classes for arranging contents visually on the screen. Here you use two of them for the main navigation views:

  • HBox layout container lays out its contents in a row
  • Panel container (also used in the first two tutorials), lays out contents horizontally or vertically, and provides a title bar

For the Panel, use data binding to link the height of the Panel container to the height of the TabNavigator container. This is a useful technique for creating relative sizing and minimizing hard-coded sizes that would be tedious to maintain in later UI makeovers or in porting the application to a different display device. You achieve data binding here through curly braces: { and }. The curly braces indicate that the Flex compiler should evaluate the contents inside as an ActionScript expression or variable.

  1. Inside the TabNavigator container block, add an HBox container block with the label "View 1: Form/Tile":

    <mx:HBox label="View 1: Form/Tile">.
    </mx:HBox>
    
  2. After the HBox container block, add a Panel container with the label View 2: Pseudo Bar Chart, and id, height, and title properties as follows:

    <mx:Panel id="barPanel" label="View 2: Pseudo Bar Chart" title="Pseudo Bar Chart" height="{.9*tabNav.height}">
    </mx:Panel